<template>
  <div class="profile">
    <div class="profile-head_image"></div>
    <div class="profile-info">
      <p class="info-item">{{ user_name }}</p>
      <p class="info-item">{{ user_age }}</p>
    </div>
  </div>

  <div>
    <p class="btn-update">
      <button class="action" @click="$emit('updateAge', incrAge)" :incrAge="incrAge">
        update age
      </button>
      <input type="text" name="user_age" v-model="incrAge" />
    </p>
    <p class="btn-update">
      <button class="action" @click="changeNameCB">change name CB</button>
      <button class="action" @click="changeNameEmit">change name</button>
    </p>
  </div>
</template>

<script>
export default {
  name: 'user-profile',
  props: {
    user_name: {
      type: String,
      default: 'Anonymous'
    },
    user_age: {
      type: Number,
      default: 18
    },
    changeNameCB: Function
  },
  emits: ['updateAge', 'changeName'],
  data() {
    return {
      incrAge: 1
    }
  },
  methods: {
    changeNameEmit() {
      this.$emit('changeName')
    }
  }
}
</script>

<style scoped lang="scss">
.profile {
  display: flex;
  align-items: flex-end;
  gap: 10px;

  &-head_image {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #cfcfcf;
  }

  & .profile-info .info-item {
    font-size: 18px;
    font-weight: 800;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 0;
  }
}

.btn-update {
  input {
    width: 20px;
    border: none;
    border-bottom: 1px solid #111;
  }
  .action {
    background-color: #fff;
    border: none;
    &:active {
      transform: scale(1.5);
      color: #fff;
      background-color: #000;
      font-weight: 700;
      border-radius: 20px;
    }
  }
}
</style>
